<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/art-template(1).js"></script>
    <script src="./js/jquery.min.js"></script>
    <style>
        *{ 
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .content{ 
            width: 1000px;
            margin: 0 auto;
        }
        ul{ 
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
        }

        li{ 
            width: 23%;
            height: 300px;
            border: 1px solid #000;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            margin-bottom:15px;
        }

        li img{ 
           width: 80%; 
        }
    </style>
</head>

<body>
    <h1>shop页面</h1>
    <div class="content"></div>
    <!-- 定义一个模板 -->
    <script id="list" type="text/html">
        <ul>
            {{each data as item}}
            <li>
                <img src="{{item.url}}" alt="">
                <h3>{{itme.title}}</h3>
                <p>{{itme.desc_1}}</p>
                <p>价格:<span>{{itme.price}}</span>元 <button>购物车</button></p>
            </li>
            {{/each}}
        </ul>
    </script>
    <script>
        /* 
        页面打开后直接获取xiaomi数据库中xiao_mi这个表格中的所有数据
        与模板结合
        渲染在页面上
        */


        fetch('/homelist').then((data) => {
            return data.json();
        }).then((res) => {
            console.log(res);
            var text = template('list',res)
            document.querySelector('.content').innerHTML = text;
        })


    </script>
</body>

</html>